package com.alpha.bom;

/**
 * This class is a container of the student's
 * answer to the a question.
 * 
 * @author Ritz Daniel C. Ang
 *
 */
public class Answer {
	private int answerId;
	private String answer;
	
	/**
	 * Is a constructor of the Answer class that
	 * initializes the answerId of the answer.
	 * 
	 * @param answerId Int value of the answer ID.
	 */
	public Answer(int answerId){
		this.setAnswerId(answerId);
	}

	
	/**
	 * Is a constructor of the Answer class that initializes
	 * the answerId of the answer and the answer text itself.
	 * 
	 * @param answerId Int value of the answer ID.
	 * @param answer String value of the answer itself.
	 */
	public Answer(int answerId, String answer){
		this.setAnswerId(answerId);
		this.answer = answer;
	}
	
	/**
	 * Is a constructor of the Answer class that initializes
	 * the answer text itself.
	 * 
	 * @param answer String value of the answer itself.
	 */
	public Answer(String answer){
		this.setAnswerId(0);
		this.answer = answer;
	}
	
	/**
	 * Gets the answer ID.
	 * 
	 * @return Int value of the answer ID.
	 */
	public int getAnswerId() {
		return answerId;
	}
	
	/**
	 * Sets the answer ID.
	 * 
	 * @param answerId Int value of the answer ID.
	 */
	public void setAnswerId(int answerId) {
		this.answerId = answerId;
	}
	
	/**
	 * Gets the answer in String form.
	 * 
	 * @return String form of the answer.
	 */
	public String getAnswer() {
		return answer;
	}
	
	/**
	 * Sets the answer in String form.
	 * 
	 * @param answer String form of the answer.
	 */
	public void setAnswer(String answer) {
		this.answer = answer;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + answerId;
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Answer other = (Answer) obj;
		if (answerId != other.answerId)
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Answer [answerId=" + answerId + ", answer=" + answer
				+ "]";
	}
}
